﻿namespace LeadMaster.Controllers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Microsoft.SqlServer.Dts.Runtime;

    public class SSISController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult RunOutSourcerLeadsImport()
        {
			if (false)
			{
            try
            {
                string pkgLocation;
                Package pkg;
                Application app;
                DTSExecResult pkgResults;
                string filePath = Server.MapPath(Url.Content("~/SSIS/"));

                pkgLocation = filePath + @"\BoilerLeadImport.dtsx";
                app = new Application();
                pkg = app.LoadPackage(pkgLocation, null);
                pkgResults = pkg.Execute();
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = "Create Lead " + e.LineNumber().ToString() + " : " + e.Message;
                return View("Errormessages");
            }
			}
            return View("Index");
        }

		public ActionResult Test()
		{
      try
      {
        string pkgLocation;
        Package pkg;
        Application app;
        DTSExecResult pkgResults;
        return View("Index");
      }
      catch (Exception e)
      {
        ViewBag.ErrorMessage = "SSIS " + e.LineNumber().ToString() + " : " + e.Message + " - " + e.InnerException;
        return View("Errormessages");
      }



		}

    }
}
